package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Organization;
import cn.wolfcode.crm.mapper.OrganizationMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IOrganizationService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
@Service
public class OrganizationServiceImpl implements IOrganizationService {
    @Autowired
    private OrganizationMapper mapper;
    @Override
    public List<Organization> selectAll() {
        return mapper.selectAll();
    }

    @Override
    public PageResult query(QueryObject qo) {
        int count = mapper.query4Count(qo);
        if (count > 0) {
            return new PageResult(count, mapper.query4List(qo));
        }
        return new PageResult(count, Collections.EMPTY_LIST);
    }

    @Override
    public void insert(Organization record) {
        mapper.insert(record);
    }

    @Override
    public void updateByPrimaryKey(Organization dept) {
        mapper.updateByPrimaryKey(dept);
    }
    public void changeState(Long id) {
        mapper.changeState(id);
    }

    @Override
    public Organization selectId(Long id) {
        return  mapper.selectByPrimaryKey(id);
    }

}
